<template>
  <div class="header">
    <div class="el-btn">
      <!-- <i v-if="!collapse" class="el-icon-s-fold"></i>
      <i v-else class="el-icon-s-unfold"></i> -->
      <img src="../assets/img/study.jpeg" alt="">
      <span>在线学习编程</span>
    </div>
    <!-- <div class="logo">
      在线学习编程导航</div> -->
    <div class="hader-riaght">
      <div class="header-icon">
        <!-- 用户头像区域 -->
        <div class="user-logo">
          <!-- <img src="../assets/img/img1.jpg" alt=""> -->
          <img src="../assets/img/user.jpeg" />
        </div>
        <!-- 用户下拉菜单下拉菜单 -->
        <div class="user-name">
          <el-dropdown class="user-name" trigger="click" @command="select">
            <span class="el-dropdown-link"
              >{{ username }}
              <i class="el-icon-caret-bottom"></i>
            </span>
            <template #dropdown>
              <el-dropdown-menu>
                <a href="#">
                  <el-dropdown-item>github地址</el-dropdown-item>
                </a>
                <el-dropdown-item divided command="Logout"
                  >Logout</el-dropdown-item
                >
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
      </div>
    </div>
  </div>
</template>
<script lang="ts">
import { Options, Vue } from "vue-class-component";

@Options({
  props: {
    // msg: String,
  },
  data() {
    return {
      // drawer: false,
      direction: "ltr",
    };
  },
  computed: {
    username() {
      let username = localStorage.getItem("username");
      return username ? username : this.name;
    },
    collapse() {
      return this.$store.state.collapse;
    },
  },
  methods: {
    // 用户名下拉菜单选择事件
    handleCommand(command) {
      if (command == "loginout") {
        localStorage.removeItem("username");
        this.$router.push("/login");
      }
    },
  },
  mounted() {
    // if (document.body.clientWidth < 1500) {
    //   this.collapseChage();
    // }
  },
})
export default class HelloWorld extends Vue {
  // msg!: string;
}
</script>
<style scoped lang="less">
.header {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  height: 70px;
  font-size: 22px;
  color: #fff;
  // background-color: #222;
}
.el-btn {
  float: left;
  padding-left: 25px;
  width: 350px;
  height: 100%;
  // text-align: center;
  line-height: 65px;
}
.el-btn  img{
  display:inline-block;
  vertical-align: middle;
  width: 100px;
  height: 50px;
  background-color: pink;
}
.el-btn span{
  display: inline-block;
  margin-left: 20px;
}

.hader-riaght {
  float: right;
  padding-right: 50px;
  // background-color: #ccc;
}
.header-icon {
  display: flex;
  height: 70px;
  align-items: center;
}
.user-logo {
  margin-left: 30px;
}
.user-logo img {
  width: 60px;
  height: 60px;
  display: block;
  border-radius: 50%;
}
.user-name {
  margin-left: 30px;
}
.el-dropdown-link {
  display: block;
  cursor: pointer;
  color: #fff;
}
.el-icon-arrow-down {
  font-size: 24px;
}
</style>
